package com.iot08.common.utils.response;

import com.iot08.common.utils.MessageUtils;
import java.util.HashMap;
import java.util.Map;

/**
 * @version 1.0
 * @Description: 请求响应
 * @author: Rock
 * @time: 2020/11/3 16:53
 */
public class ResponseMap extends HashMap {

    /**
     * @time: 2020/11/6 14:16
     * @author: Rock
     * @version 1.0
     */
    public static ResponseMap fail() {
        ResponseMap map = new ResponseMap();
        map.put("code", ResponseEnum.STATUS400.getCode());
        return map;
    }

    /**
     * @param msg
     * @time: 2020/11/20 15:34
     * @author: Rock
     * @version 1.0
     */
    public static ResponseMap fail(String msg) {
        ResponseMap map = new ResponseMap();
        map.put("code", ResponseEnum.STATUS400.getCode());
        map.put("msg", msg);
        return map;
    }

    /**
     * @param code
     * @time: 2020/11/3 16:55
     * @author: Rock
     * @version 1.0
     */
    public static ResponseMap fail(int code) {
        ResponseMap map = new ResponseMap();
        map.put("code", code);
        return map;
    }


    /**
     * 国际化语言提示 根据请求中的 头部的语言标识返回对应的语音 提示
     * @param code
     * @param msgKeyCode
     * @return
     */
    public static ResponseMap fail(int code, String msgKeyCode) {
        ResponseMap map = new ResponseMap();
        map.put("code", code);
        map.put("msg", MessageUtils.getLocale(msgKeyCode));
        return map;
    }

    /**
     * 国际化语言提示(带参) 根据请求中的 头部的语言标识返回对应的语音 提示
     * @param code
     * @param msgKeyCode
     * @param args
     * @time: 1/20/22 9:56 AM
     * @author: Weichao
     * @version 1.0
     */
    public static ResponseMap fail(int code, String msgKeyCode, Object... args) {
        ResponseMap map = new ResponseMap();
        map.put("code", code);
        map.put("msg", MessageUtils.getLocale(msgKeyCode,args));
        return map;
    }



    /**
     * @time: 2020/11/3 16:59
     * @author: Rock
     * @version 1.0
     */
    public static ResponseMap success() {
        ResponseMap map = new ResponseMap();
        map.put("code", ResponseEnum.STATUS0.getCode());
        return map;
    }

    /**
     * @description 
     * @author cwj
     * @param [msg]
     * @return com.iot08.common.utils.response.ResponseMap
     * @date @time 2025/2/14 15:06
     **/
    public static ResponseMap success(String msg) {
        ResponseMap map = new ResponseMap();
        map.put("code", ResponseEnum.STATUS0.getCode());
        map.put("msg", msg);
        return map;
    }
    /**
     * @time: 2020/11/3 16:59
     * @author: Rock
     * @version 1.0
     */
    public static ResponseMap success(Map successOB) {
        ResponseMap map = new ResponseMap();
        map.put("code", ResponseEnum.STATUS0.getCode());
        if(successOB.size() > 0){
            map.putAll(successOB);
        }
        return map;
    }

}
